package com.sutong.client.config;

import com.sutong.client.service.Client;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * Client配置
 *
 * @author sutong
 * @date 2024-07-11 9:50
 */
@Configuration
public class ClientConfig {
    @Resource
    private ClientProperties clientProperties;

    @Resource
    private RestTemplate restTemplate;

    @Bean
    @ConditionalOnProperty(prefix = "sutongapi.client", name = "enable")
    public Client client() {
        String accessKey = clientProperties.getAccessKey();
        String secretKey = clientProperties.getSecretKey();
        return new Client(accessKey, secretKey, restTemplate);
    }

}
